package camel.first.api.javaProcessor;

import camel.first.api.service.IXMLParserService;
import org.apache.camel.Exchange;
import org.apache.camel.Processor;
import org.apache.camel.builder.RouteBuilder;
import org.codehaus.jackson.map.type.TypeFactory;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.BeanInitializationException;
import org.springframework.beans.factory.DisposableBean;
import org.springframework.beans.factory.InitializingBean;

import java.lang.reflect.Type;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * User: yuxinlei
 * Date: 4/8/11
 * Time: 2:03 AM
 */
public class HudsonMapProcessorRouter extends RouteBuilder implements InitializingBean, DisposableBean {
    private static final Logger logger = LoggerFactory.getLogger(HudsonMapProcessorRouter.class)  ;

    private String incomeQueueName = "xmlFileQueue";
    private String outcomeQueueName = "store";
    private Processor processor;

    @Override
    public void configure() {
        from(incomeQueueName)
        .process(processor ).unmarshal().json().convertBodyTo(Map.class)
        .to(outcomeQueueName);

    }

    public void destroy() {
        logger.debug("Shutting down the processor route.");
    }

    public void afterPropertiesSet() {
        logger.debug("Initializing the processor route!");
    }



    public Processor getProcessor() {
        return processor;
    }

    public void setProcessor(Processor processor) {
        this.processor = processor;
    }

    public String getIncomeQueueName() {
        return incomeQueueName;
    }

    public void setIncomeQueueName(String incomeQueueName) {
        this.incomeQueueName = incomeQueueName;
    }

    public String getOutcomeQueueName() {
        return outcomeQueueName;
    }

    public void setOutcomeQueueName(String outcomeQueueName) {
        this.outcomeQueueName = outcomeQueueName;
    }
}
